﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;

namespace WoChu.RfClient.Duty
{
    public class ProdOnShelvesOrderUIRule:IProdOnShelvesOrder
    {
        private static ProdOnShelvesOrderUIRule _NewInstance = new ProdOnShelvesOrderUIRule();

        public static ProdOnShelvesOrderUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new ProdOnShelvesOrderUIRule();
                }

                return _NewInstance;
            }
        }
        /// <summary>
        /// 获取指令上架
        /// </summary>
        /// <param name="batchNo"></param>
        /// <param name="onShelvesDate"></param>
        /// <returns></returns>
        public ResultModel<List<OnShelvesInfo>> GetOnShelvesInfo(string batchNo, DateTime onShelvesDate)
        {
            try
            {
                ResultModel<List<OnShelvesInfo>> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IProdOnShelvesOrder>.NewInstance.InvokeWebMethod < ResultModel<List<OnShelvesInfo>>>("GetOnShelvesInfo", new object[] { batchNo, onShelvesDate });

                if (_result == null)
                    return new ResultModel<List<OnShelvesInfo>>().GetInstance();
                return _result; 
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return new ResultModel<List<OnShelvesInfo>>().GetInstance();
        }
        /// <summary>
        /// 获取箱号数据
        /// </summary>
        /// <param name="boxCode"></param>
        /// <param name="goodsCode"></param>
        /// <returns></returns>
        public ResultModel<GoodsBoxes> GetGoodsBoxByBoxCode(string boxCode)
        {
            try
            {
                ResultModel<GoodsBoxes> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IProdOnShelvesOrder>.NewInstance.InvokeWebMethod < ResultModel<GoodsBoxes>>("GetGoodsBoxesByBoxCode", new object[] { boxCode });
                if (_result == null)
                    return new ResultModel<GoodsBoxes>().GetInstance();
                return _result; 
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<GoodsBoxes>().GetInstance();
            }
    
        }
        /// <summary>
        /// 提交成品指令
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="batchNo"></param>
        /// <param name="rationDate"></param>
        /// <param name="lstOnShelves"></param>
        /// <returns></returns>
        public ResultModel<bool> SetProdOnShelves(string userID, List<GoodsBoxes> lstGoodsBoxes)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IProdOnShelvesOrder>.NewInstance.InvokeWebMethod<List<GoodsBoxes>, ResultModel<bool>>("SetProdOnShelves", new object[] { userID }, lstGoodsBoxes);

                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result; 
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<bool>().GetInstance();
            }
       
        }
    }
}
